//
//  CustomTabBarController.m
//  Medicine.Power
//
//  Created by 钟毅灵 on 15/8/3.
//  Copyright (c) 2015年 钟毅灵. All rights reserved.
//

#import "CustomTabBarController.h"
#import "HomeViewController.h"
#import "NewsViewController.h"
#import "RemindViewController.h"
#import "MeViewController.h"

@interface CustomTabBarController ()

@end

@implementation CustomTabBarController

- (instancetype) init {
    self = [super init];
    
    if (self) {
        [self.view setBackgroundColor:[UIColor whiteColor]];
        
        
        HomeViewController *homeView = [[HomeViewController alloc] init];
        UIViewController *homeNav = [[UINavigationController alloc] initWithRootViewController:homeView];
        
        NewsViewController *newsView = [[NewsViewController alloc] init];
        UIViewController *newsNav = [[UINavigationController alloc] initWithRootViewController:newsView];
        
        RemindViewController *remindView = [[RemindViewController alloc] init];
        UIViewController *remindNav = [[UINavigationController alloc] initWithRootViewController:remindView];
        
        MeViewController *meView = [[MeViewController alloc] init];
        UIViewController *meNav = [[UINavigationController alloc] initWithRootViewController:meView];
        
        self.viewControllers = [NSArray arrayWithObjects:homeNav, newsNav, remindNav, meNav, nil];
        
        NSArray *titleArray = @[@"购药", @"问诊", @"提醒", @"我的"];
        NSArray *imageArray = @[@"", @"", @"", @""];
        
        UITabBar *tabBar = self.tabBar;
        
        [self.tabBar.items enumerateObjectsUsingBlock:^(id tab, NSUInteger idx, BOOL *stop) {
            [tab setTitle:titleArray[idx]];
            [tab setImage:[UIImage imageNamed:[imageArray objectAtIndex:idx]]];
        }];
        
        tabBar.selectedImageTintColor = RGB(255, 182, 113, 1);
        
        [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: RGB(117, 117, 117, 1), NSForegroundColorAttributeName, [UIFont systemFontOfSize:12], NSFontAttributeName,nil] forState:UIControlStateNormal];
        
        [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: RGB(255, 182, 113, 1), NSForegroundColorAttributeName, [UIFont systemFontOfSize:12], NSFontAttributeName, nil] forState:UIControlStateSelected];
    }
    
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
